// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.TransformManagement
{
	public sealed partial class Latest
	{
		[JsonInclude]
		[JsonPropertyName("sort")]
		public Elastic.Clients.Elasticsearch.Field Sort { get; set; }

		[JsonInclude]
		[JsonPropertyName("unique_key")]
		public IEnumerable<Elastic.Clients.Elasticsearch.Field> UniqueKey { get; set; }
	}

	public sealed partial class LatestDescriptor<TDocument> : SerializableDescriptorBase<LatestDescriptor<TDocument>>
	{
		internal LatestDescriptor(Action<LatestDescriptor<TDocument>> configure) => configure.Invoke(this);
		public LatestDescriptor() : base()
		{
		}

		private Elastic.Clients.Elasticsearch.Field SortValue { get; set; }

		private IEnumerable<Elastic.Clients.Elasticsearch.Field> UniqueKeyValue { get; set; }

		public LatestDescriptor<TDocument> Sort(Elastic.Clients.Elasticsearch.Field sort)
		{
			SortValue = sort;
			return Self;
		}

		public LatestDescriptor<TDocument> Sort<TValue>(Expression<Func<TDocument, TValue>> sort)
		{
			SortValue = sort;
			return Self;
		}

		public LatestDescriptor<TDocument> UniqueKey(IEnumerable<Elastic.Clients.Elasticsearch.Field> uniqueKey)
		{
			UniqueKeyValue = uniqueKey;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			writer.WritePropertyName("sort");
			JsonSerializer.Serialize(writer, SortValue, options);
			writer.WritePropertyName("unique_key");
			JsonSerializer.Serialize(writer, UniqueKeyValue, options);
			writer.WriteEndObject();
		}
	}

	public sealed partial class LatestDescriptor : SerializableDescriptorBase<LatestDescriptor>
	{
		internal LatestDescriptor(Action<LatestDescriptor> configure) => configure.Invoke(this);
		public LatestDescriptor() : base()
		{
		}

		private Elastic.Clients.Elasticsearch.Field SortValue { get; set; }

		private IEnumerable<Elastic.Clients.Elasticsearch.Field> UniqueKeyValue { get; set; }

		public LatestDescriptor Sort(Elastic.Clients.Elasticsearch.Field sort)
		{
			SortValue = sort;
			return Self;
		}

		public LatestDescriptor Sort<TDocument, TValue>(Expression<Func<TDocument, TValue>> sort)
		{
			SortValue = sort;
			return Self;
		}

		public LatestDescriptor Sort<TDocument>(Expression<Func<TDocument, object>> sort)
		{
			SortValue = sort;
			return Self;
		}

		public LatestDescriptor UniqueKey(IEnumerable<Elastic.Clients.Elasticsearch.Field> uniqueKey)
		{
			UniqueKeyValue = uniqueKey;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			writer.WritePropertyName("sort");
			JsonSerializer.Serialize(writer, SortValue, options);
			writer.WritePropertyName("unique_key");
			JsonSerializer.Serialize(writer, UniqueKeyValue, options);
			writer.WriteEndObject();
		}
	}
}